﻿using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;

using System.Data.SqlTypes;
using System.Collections.Generic;
using BPM.Foundation.WFService;
using BPM.Foundation.WFDB;
namespace BPM.Base.WFLib
{
    [System.Drawing.ToolboxBitmap(typeof(发送消息), "pic.message.png")]
    public partial class 发送消息 : Activity
    {



        #region 方法

        //[4.1]
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            //[1 发送消息 ]
            WorkflowService service = executionContext.GetService(typeof(WorkflowService)) as WorkflowService;
            if (service != null)
            {

                WF_Message wfMessage = new WF_Message();
                wfMessage.content1 = this.消息内容1;
                wfMessage.content2 = this.消息内容2;
                wfMessage.content3 = this.消息内容3;
                wfMessage.content4 = this.消息内容4;

                wfMessage.firstSeeTime = SqlDateTime.MinValue.Value;
                wfMessage.head = this.消息头;
                wfMessage.ID = Guid.NewGuid();
                wfMessage.inceptDepartmentNo = this.接收部门;
                wfMessage.inceptDutyNo = this.接收职能;
                wfMessage.inceptUserNo = this.接收人;
                if (this.是否需要回复)
                {
                    wfMessage.isNeedRevert = 1;
                }
                else
                {
                    wfMessage.isNeedRevert = 0;
                }

                wfMessage.parentId = Guid.Empty;
                wfMessage.revertState = "";
                wfMessage.revertTime = new DateTime(1900, 1, 1);
                wfMessage.secrecy = this.保密度;

                wfMessage.sendDepartmentNo = this.发送部门;
                wfMessage.sendDutyNo = this.发送职能;
                wfMessage.sendUserNo = this.发送人;
                wfMessage.sendTime = DateTime.Now;
                wfMessage.state = "没看";
                wfMessage.type = this.消息类型;
                wfMessage.urgency = this.紧急度;


                service.insertWFMessage("", wfMessage);

            }
            else
            {
                List<string> ls = executionContext.GetService(typeof(List<string>)) as List<string>;
                if (ls != null)
                {
                    ls.Add("--------------------------发送消息-----------------------------------");
                    ls.Add("流程编号:" + this.WorkflowInstanceId.ToString());
                    ls.Add("消息头:" + this.消息头);
                    ls.Add("消息内容1:" + this.消息内容1);
                    ls.Add("接收部门:" + this.接收部门);
                    ls.Add("接收职能:" + this.接收职能);
                    ls.Add("接收人:" + this.接收人);
                    ls.Add("");
                }
            }

            //[end]
            return base.Execute(executionContext);

        }

        #endregion

        #region 01 一般信息

        //[1.1消息编号]
        public static DependencyProperty 消息编号Property = DependencyProperty.Register("消息编号", typeof(Guid), typeof(发送消息), new PropertyMetadata(Guid.Empty));

        [DescriptionAttribute("消息编号")]
        [CategoryAttribute("01 一般信息")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public Guid 消息编号
        {
            get
            {
                return ((Guid)(base.GetValue(发送消息.消息编号Property)));
            }
            set
            {
                base.SetValue(发送消息.消息编号Property, value);
            }
        }
        //--

        //[1.2 消息头]
        public static DependencyProperty 消息头Property = DependencyProperty.Register("消息头", typeof(string), typeof(发送消息));

        [DescriptionAttribute("消息头")]
        [CategoryAttribute("01 一般信息")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public string 消息头
        {
            get
            {
                return ((string)(base.GetValue(发送消息.消息头Property)));
            }
            set
            {
                base.SetValue(发送消息.消息头Property, value);
            }
        }
        //--


        //[1.3 消息内容1]
        public static DependencyProperty 消息内容1Property = DependencyProperty.Register("消息内容1", typeof(string), typeof(发送消息));

        [DescriptionAttribute("消息内容1")]
        [CategoryAttribute("01 一般信息")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public string 消息内容1
        {
            get
            {
                return ((string)(base.GetValue(发送消息.消息内容1Property)));
            }
            set
            {
                base.SetValue(发送消息.消息内容1Property, value);
            }
        }
        //--

        //[1.4 消息内容2]
        public static DependencyProperty 消息内容2Property = DependencyProperty.Register("消息内容2", typeof(string), typeof(发送消息));

        [DescriptionAttribute("消息内容2")]
        [CategoryAttribute("01 一般信息")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public string 消息内容2
        {
            get
            {
                return ((string)(base.GetValue(发送消息.消息内容2Property)));
            }
            set
            {
                base.SetValue(发送消息.消息内容2Property, value);
            }
        }
        //--

        //[1.5 消息内容3]
        public static DependencyProperty 消息内容3Property = DependencyProperty.Register("消息内容3", typeof(string), typeof(发送消息));

        [DescriptionAttribute("消息内容3")]
        [CategoryAttribute("01 一般信息")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public string 消息内容3
        {
            get
            {
                return ((string)(base.GetValue(发送消息.消息内容3Property)));
            }
            set
            {
                base.SetValue(发送消息.消息内容3Property, value);
            }
        }
        //--

        //[1.6 消息内容4]
        public static DependencyProperty 消息内容4Property = DependencyProperty.Register("消息内容4", typeof(string), typeof(发送消息));

        [DescriptionAttribute("消息内容4")]
        [CategoryAttribute("01 一般信息")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public string 消息内容4
        {
            get
            {
                return ((string)(base.GetValue(发送消息.消息内容4Property)));
            }
            set
            {
                base.SetValue(发送消息.消息内容4Property, value);
            }
        }
        //--

        //[1.7 消息类型]
        public static DependencyProperty 消息类型Property = DependencyProperty.Register("消息类型", typeof(string), typeof(发送消息), new PropertyMetadata("系统"));

        [DescriptionAttribute("消息类型")]
        [CategoryAttribute("01 一般信息")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public string 消息类型
        {
            get
            {
                return ((string)(base.GetValue(发送消息.消息类型Property)));
            }
            set
            {
                base.SetValue(发送消息.消息类型Property, value);
            }
        }
        //--

        //[1.8 保密度]
        public static DependencyProperty 保密度Property = DependencyProperty.Register("保密度", typeof(string), typeof(发送消息));

        [DescriptionAttribute("保密度")]
        [CategoryAttribute("01 一般信息")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public string 保密度
        {
            get
            {
                return ((string)(base.GetValue(发送消息.保密度Property)));
            }
            set
            {
                base.SetValue(发送消息.保密度Property, value);
            }
        }
        //--

        //[1.9 紧急度]
        public static DependencyProperty 紧急度Property = DependencyProperty.Register("紧急度", typeof(string), typeof(发送消息));

        [DescriptionAttribute("紧急度")]
        [CategoryAttribute("01 一般信息")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public string 紧急度
        {
            get
            {
                return ((string)(base.GetValue(发送消息.紧急度Property)));
            }
            set
            {
                base.SetValue(发送消息.紧急度Property, value);
            }
        }
        //--



        //[1.10 是否需要回复]
        public static DependencyProperty 是否需要回复Property = DependencyProperty.Register("是否需要回复", typeof(bool), typeof(发送消息), new PropertyMetadata(false));

        [DescriptionAttribute("是否需要回复")]
        [CategoryAttribute("01 一般信息")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public bool 是否需要回复
        {
            get
            {
                return ((bool)(base.GetValue(发送消息.是否需要回复Property)));
            }
            set
            {
                base.SetValue(发送消息.是否需要回复Property, value);
            }
        }
        //--



        #endregion

        #region 02 消息发送人
        //[2.1 发送部门]
        public static DependencyProperty 发送部门Property = DependencyProperty.Register("发送部门", typeof(string), typeof(发送消息));

        [DescriptionAttribute("发送部门")]
        [CategoryAttribute("02 消息发送人")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public string 发送部门
        {
            get
            {
                return ((string)(base.GetValue(发送消息.发送部门Property)));
            }
            set
            {
                base.SetValue(发送消息.发送部门Property, value);
            }
        }
        //--

        //[2.2 发送职能]
        public static DependencyProperty 发送职能Property = DependencyProperty.Register("发送职能", typeof(string), typeof(发送消息));

        [DescriptionAttribute("发送职能")]
        [CategoryAttribute("02 消息发送人")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public string 发送职能
        {
            get
            {
                return ((string)(base.GetValue(发送消息.发送职能Property)));
            }
            set
            {
                base.SetValue(发送消息.发送职能Property, value);
            }
        }
        //--

        //[2.3 发送人]
        public static DependencyProperty 发送人Property = DependencyProperty.Register("发送人", typeof(string), typeof(发送消息));

        [DescriptionAttribute("发送人")]
        [CategoryAttribute("02 消息发送人")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public string 发送人
        {
            get
            {
                return ((string)(base.GetValue(发送消息.发送人Property)));
            }
            set
            {
                base.SetValue(发送消息.发送人Property, value);
            }
        }

        #endregion

        #region 03 消息接收人
        //--

        //[2.4接收部门]
        public static DependencyProperty 接收部门Property = DependencyProperty.Register("接收部门", typeof(string), typeof(发送消息));

        [DescriptionAttribute("接收部门")]
        [CategoryAttribute("03 消息接收人")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public string 接收部门
        {
            get
            {
                return ((string)(base.GetValue(发送消息.接收部门Property)));
            }
            set
            {
                base.SetValue(发送消息.接收部门Property, value);
            }
        }
        //--

        //[2.5接收职能]
        public static DependencyProperty 接收职能Property = DependencyProperty.Register("接收职能", typeof(string), typeof(发送消息));

        [DescriptionAttribute("接收职能")]
        [CategoryAttribute("03 消息接收人")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public string 接收职能
        {
            get
            {
                return ((string)(base.GetValue(发送消息.接收职能Property)));
            }
            set
            {
                base.SetValue(发送消息.接收职能Property, value);
            }
        }
        //--

        //[2.6接收人]
        public static DependencyProperty 接收人Property = DependencyProperty.Register("接收人", typeof(string), typeof(发送消息));

        [DescriptionAttribute("接收人")]
        [CategoryAttribute("03 消息接收人")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public string 接收人
        {
            get
            {
                return ((string)(base.GetValue(发送消息.接收人Property)));
            }
            set
            {
                base.SetValue(发送消息.接收人Property, value);
            }
        }

        private void InitializeComponent()
        {
            // 
            // 消息
            // 
            this.Name = "消息";

        }
        //--
        #endregion



    }
}
